#include "pch.h"
#include <iostream>
#include <string>
#include <map>

using namespace std;

class Solution {
public:
	string reverseVowels(string s) {
		int len = s.length();
		if (len < 2) return s;

		map<char, int> vowel{
			{'a',0},
			{'e',1},
			{'i',2},
			{'o',3},
			{'u',4},
			{'A',5},
			{'E',6},
			{'I',7},
			{'O',8},
			{'U',9},
		};

		int i = 0, j = len - 1;
		char temp;
		while (i < j)
		{
			while (vowel.find(s[i]) == vowel.end() && i<j)
			{
				i++;
			}
			while (vowel.find(s[j]) == vowel.end() && i<j)
			{
				j--;
			}
			if (i < j)
				swap(s[i++],s[j--]);
		}
		return s;
	}
};


int main()
{
	string str = "aA";
	Solution s;
	string res = s.reverseVowels(str);

	cout << res << endl;
	return 0;
}